package com.atguigu.guli.service.base.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.util.Date;


/**
 * @Date 2021/5/18 11:02
 * @Description TODO
 */
@Configuration
public class GuliMetaObjectHandler implements MetaObjectHandler {

    @Override  //插入数据时 需要自动填充的对象
    public void insertFill(MetaObject metaObject) {
//metaObject 需要新增自动填充的对象
        metaObject.setValue("gmtCreate", new Date());
        metaObject.setValue("gmtModified", new Date());
    }

    @Override  //更新数据时 需要自动填充的对象
    public void updateFill(MetaObject metaObject) {
metaObject.setValue("gmtModified", new Date());
    }
}
